function animate(ele, obj, callback){
    clearInterval(ele.t);
    ele.t = setInterval(() => {
        let flag = true;
        for(let attr in obj){
            let now = attr === "opacity" ? getStyle(ele, "opacity") * 100 : parseInt(getStyle(ele, attr));

            let speed = (obj[attr]-now) / 10;
            speed = speed>0 ? Math.ceil(speed) : Math.floor(speed);

            if(now !== obj[attr]) flag = false;
            
            ele.style[attr] = attr === "opacity" ? (now+speed) / 100 : now + speed + "px";
        }
        if(flag){
            clearInterval(ele.t)
            callback && callback();
        }
    }, 30);
}

function getStyle(ele, attr){
    return getComputedStyle ? getComputedStyle(ele,false)[attr] : ele.currentStyle[attr];
}